﻿using System.Collections.Generic;
using System.Linq;
using BabyShop.WebSite.Exts.Extensions;

namespace BabyShop.WebSite.Data.Conventions.Combines
{
    public class AndCombineConvention : IExpressionCombineConvention
    {
        public int Order { get; set; }
        public System.Linq.Expressions.Expression Combine(IDictionary<string, System.Linq.Expressions.Expression> expressions)
        {
            return expressions.Count > 0 ? expressions.Values.Aggregate((a, e) => a.AndAlso(e)) : null;
        }
    }
}